<?php

namespace Domain\Task;

use Domain\Task\TaskRepository;

class TaskService {

    public function submitTask(TaskTO $oTask) {
        $oRepository = new TaskListRepository();
        return $oRepository->Insert($oTask);
    }

    public function openTask($iTaskID) {
        $oTaskRepository = new TaskRepository();
        $oTaskTO = $oTaskRepository->Find($iTaskID);

        $oTask = new Task(new TaskStatus($oTaskTO->getStatus()), new DateTime($oTaskTO->getCreationDate()));
        $oTask->setDescription($oTaskTO->getDescription())
              ->setDeadline(new DateTime($oTaskTO->getDeadline()))
              ->setActDate(new DateTime($oTaskTO->getActDate()));
    }

    public function changeTask(TaskTO $oTask) {
        $oRepository = new TaskListRepository();
        return $oRepository->Update($oList);
    }

    public function removeTask($iTaskID) {
        $oRepository = new TaskListRepository();
        return $oRepository->deleteListByUserID($iTaskID);
    }

}

?>
